<?
  class DataWrapper {
      private $properties;
      private $editing_mode;
      private $ignore;
      protected $errors;
      
      function __construct($properties) {
          $this->properties = array();
          foreach($properties as $key => $item) {
              if(!in_array($key,$this->ignore)) {
                  $this->add_property($key, $item);
              }
          }
          $this->editing_mode = false;
      }
      
      public function add_ignore($item) {
          $this->ignore[] = $item;
      }
      
      public function add_property($key, $item) {
          $search = array(chr(145),chr(146),chr(147),chr(148),chr(151));
          $replace = array("'","'","\"","\"","-");
          $item = stripslashes($item);
          $item = str_replace($search, $replace, $item);
          $item = htmlentities($item,ENT_QUOTES);
          $this->properties[$key] = $item;
      }
      
      public function get_errors() {
          return $this->errors;
      }
      
      public function get_property($key) {
          if(isset($this->properties[$key])) {
              if($this->editing_mode) {
                  return str_replace("&amp;","&",$this->properties[$key]);
              } else {
                  return html_entity_decode(str_replace("&amp;","&",$this->properties[$key]));
              }
          }
          return;
      }
      
      public function properties() {
          return $this->properties;
      }
      
      public function set_edit_mode($mode) {
          $this->editing_mode = $mode;
          return $this->editing_mode;
      }
      
      public function validate() {
          if(count($this->errors) > 0) {
              return false;
          }
          return true;
      }
      
      public function write($connection) {
          return false;
      }
  }
?>
